/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Temporal;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author Julian's Lappy
 */
@Entity
public class SystemUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long userId;
    private String firstName;
    private String lastName;
    private String salutation;
    private String nric;
    private String department;
    private String position;
    private String email;
    private String contactNum;
    private String userType;
    private String userName;
    private String password;
    private int invalidLogin;
    private boolean locked;
    private boolean logged;
    private boolean firstlog;
    
     @OneToOne(cascade={CascadeType.PERSIST})
    private Address address;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private SalesInquiry saleInquiry;
    
    @OneToMany(cascade = {CascadeType.PERSIST}, mappedBy = "systemUser")
    private List<Customer> customer = new ArrayList();

   
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date createdDate;

    
    public void create(String firstName, String lastName, String salutation, 
            String nric,String department, String position, String email, 
            String contactNum, String userType, String userName, 
            String password, boolean logged, Integer invalidLogin, 
            boolean lock, Date createdDate) {
        
        this.setFirstName(firstName);
        this.setLastName(lastName);
        this.setNric(nric);
        this.setSalutation(salutation);
        this.setDepartment(department);
        this.setPosition(position);
        this.setEmail(email);
        this.setContactNum(contactNum);
        this.setUserType(userType);
        this.setUserName(userName);
        this.setPassword(password);
        this.setLogged(logged);
        this.setLock(lock);
        this.setInvalidLogin(invalidLogin);
        this.setCreatedDate(createdDate);
        this.setFirstlog(true);
    }

    
    
    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public String getContactNum() {
        return contactNum;
    }

    public void setContactNum(String contactNum) {
        this.contactNum = contactNum;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public Integer getInvalidLogin() {
        return invalidLogin;
    }

    public void setInvalidLogin(Integer invalidLogin) {
        this.invalidLogin = invalidLogin;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public boolean isLogged() {
        return logged;
    }

    public void setLogged(boolean logged) {
        this.logged = logged;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public String getSalutation() {
        return salutation;
    }

    public void setSalutation(String salutation) {
        this.salutation = salutation;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }
    
   

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (getUserId() != null ? getUserId().hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SystemUser)) {
            return false;
        }
        SystemUser other = (SystemUser) object;
        if ((this.getUserId() == null && other.getUserId() != null) || (this.getUserId() != null && !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.User[ id=" + getUserId() + " ]";
    }

    /**
     * @return the locked
     */
    public boolean isLock() {
        return locked;
    }

    /**
     * @param locked the locked to set
     */
    public void setLock(boolean lock) {
        this.locked = lock;
    }

    /**
     * @return the createdDate
     */
    public Date getCreatedDate() {
        return createdDate;
    }

    /**
     * @param createdDate the createdDate to set
     */
    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }



    /**
     * @return the nric
     */
    public String getNric() {
        return nric;
    }

    /**
     * @param nric the nric to set
     */
    public void setNric(String nric) {
        this.nric = nric;
    }

    /**
     * @return the firstlog
     */
    public boolean isFirstlog() {
        return firstlog;
    }

    /**
     * @param firstlog the firstlog to set
     */
    public void setFirstlog(boolean firstlog) {
        this.firstlog = firstlog;
    }
    
}
